package com.econ.powercloud.ems.controller;

import com.econ.powercloud.common.base.facade.pojo.MsgResult;
import com.econ.powercloud.ems.pojo.*;
import com.econ.powercloud.ems.service.biz.PrometheusMonitorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "Prometheus监控")
@RestController
@RequestMapping(value = "/api/v2/monitor/prometheus")
public class PrometheusMonitorController extends ApiBaseController{

    @Autowired
    private PrometheusMonitorService prometheusMonitorService;

    @GetMapping(value = "/node")
    @ApiOperation(value="服务器节点")
    public MsgResult<List<PrometheusNodeVO>> prometheusNodes(){
        List<PrometheusNodeVO> result = prometheusMonitorService.getNodesInfo();
        return successHandler(result);
    }

    @GetMapping(value = "/kafka")
    @ApiOperation(value="kafka节点")
    public MsgResult<List<PrometheusKafkaVO>> prometheusKafka(){
        List<PrometheusKafkaVO> result = prometheusMonitorService.getKafkaInfo();
        return successHandler(result);
    }

    @GetMapping(value = "/redis")
    @ApiOperation(value="redis节点")
    public MsgResult<List<PrometheusRedisVO>> prometheusRedis(){
        List<PrometheusRedisVO> result = prometheusMonitorService.getRedisInfo();
        return successHandler(result);
    }

    @GetMapping(value = "/clickhouse")
    @ApiOperation(value="clickhouse节点")
    public MsgResult<List<PrometheusClickhouseVO>> prometheusClickhouse(){
        List<PrometheusClickhouseVO> result = prometheusMonitorService.getClickhouseInfo();
        return successHandler(result);
    }

    @GetMapping(value = "/mysql")
    @ApiOperation(value="mysql节点")
    public MsgResult<List<PrometheusMysqlVO>> prometheusMysql(){
        List<PrometheusMysqlVO> result = prometheusMonitorService.getMysqlInfo();
        return successHandler(result);
    }
}
